<?php
class MySQL {
	public $link;
	function connect() {
		require(APP_DIR .DS.'host_config.php');
		global $link;
   		$link = mysqli_connect($mysql_host, $mysql_user, $mysql_password, $mysql_db);
		if ($link->connect_error)
			die($link->connect_error);
		$link->set_charset("utf8");
		return $link;
	}
	function real($string) {
		global $link;
		return mysqli_real_escape_string($link, $string);
	}
	function query($sql) {
		global $link;
		//return mysqli_query($link, $sql) or die("execute sql fail!!");
		return mysqli_query($link, $sql) or die(mysqli_error($link));
	}
	function query_row($sql) {
		global $link;
		$result = mysqli_query($link, $sql) or die("execute sql failed!!");
		return mysqli_fetch_row($result);
	}
	function query_array($sql) {
		global $link;
		$result = mysqli_query($link, $sql) or die("execute sql failed!!");
		return mysqli_fetch_array($result);
	}
}
?>
